﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using negocio.entidades;
using negocio.servicios;

namespace Swimmers
{
    public partial class GestionTorneo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!Page.IsPostBack)
            {
                CargarCombo();
                CargarGrillaCompetencias();
                //pnlFechas.Visible = false;
                //chkFechas.Checked = false;
            }
        }

        private void CargarCombo()
        {
            cmbClub.DataSource = TorneoService.ObtenerClubes();
            cmbClub.DataValueField = "id_club";
            cmbClub.DataTextField = "razon_social";
            cmbClub.DataBind();
         }

        private void CargarGrillaCompetencias()
        {
            gvCompetencias.DataSource = TorneoService.ObtenerCompetencias();
            string[] keys = new string[1];
            keys[0] = "id_competencia";
            gvCompetencias.DataKeyNames = keys;
            gvCompetencias.DataBind();

        }

        protected void cmdCrearT_Click(object sender, EventArgs e)
        {
            DateTime fD = DateTime.Parse(txtFechaDesde.Text);
            DateTime fH = DateTime.Parse(txtFechaHasta.Text);
            int idclub = Int32.Parse(cmbClub.SelectedValue);

            Session["id_torneo"]=TorneoService.Registrar(idclub,fD,fH);

        }
        
        protected void cmdCargarNad_Click(object sender, EventArgs e)
        {
            Session["id_competencia"] = gvCompetencias.SelectedValue;
            Response.Redirect("GestionCompetenciaNadador.aspx");
        }

        protected void txtFechaHasta_TextChanged(object sender, EventArgs e)
        {

        }
    }
}